package handler

import (
	"github.com/name5566/leaf/gate"
	"server/game/rank"
	"server/msg/jsonData"
)

func GetIncomeRank(args []interface{}) {
	m := args[0].(*jsonData.MsgGetIncomeRankReq)
	a := args[1].(gate.Agent)
	result, err := rank.GetIncomeRank(m.Page, m.PageSize)
	if err != nil {
		a.WriteMsg(&jsonData.MsgRes{Ret: 1, RequestId: m.RequestId})
		return
	}
	a.WriteMsg(&jsonData.MsgRes{Ret: 0, Result: result, RequestId: m.RequestId})
}
func GetAbilityRank(args []interface{}) {
	m := args[0].(*jsonData.MsgGetAbilityRankReq)
	a := args[1].(gate.Agent)
	result, err := rank.GetAbilityRank(m.Page, m.PageSize)
	if err != nil {
		a.WriteMsg(&jsonData.MsgRes{Ret: 1, Message: err.Error(), RequestId: m.RequestId})
		return
	}
	a.WriteMsg(&jsonData.MsgRes{Ret: 0, Result: result, RequestId: m.RequestId})
}
func GetCharmRank(args []interface{}) {
	m := args[0].(*jsonData.MsgGetCharmRankReq)
	a := args[1].(gate.Agent)
	result, err := rank.GetCharmRank(m.Page, m.PageSize)
	if err != nil {
		a.WriteMsg(&jsonData.MsgRes{Ret: 1, Message: err.Error(), RequestId: m.RequestId})
		return
	}
	a.WriteMsg(&jsonData.MsgRes{Ret: 0, Result: result, RequestId: m.RequestId})
}
func GetGuildRank(args []interface{}) {
	m := args[0].(*jsonData.MsgGetGuildRankReq)
	a := args[1].(gate.Agent)
	result, err := rank.GetGuildRank(m.Page, m.PageSize)
	if err != nil {
		a.WriteMsg(&jsonData.MsgRes{Ret: 1, Message: err.Error(), RequestId: m.RequestId})
		return
	}
	a.WriteMsg(&jsonData.MsgRes{Ret: 0, Result: result, RequestId: m.RequestId})
}
